﻿package plugin.instances.game
{
    import com.core.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import flash.utils.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.instances.*;
    import uiresource.instances.ui.*;
    import view.mornExtends.*;

    public class HeShangDianGmae extends SwdUI implements IInstance
    {
        private var _instance:Object;

        public function HeShangDianGmae()
        {
            btn_tuichu.addEventListener(MouseEvent.CLICK, this.clickHandler);
            return;
        }// end function

        protected function clickHandler(event:MouseEvent) : void
        {
            ModelProxy.change("zone", "exitInstance", null);
            return;
        }// end function

        public function initShow(param1:Object, param2:Dictionary) : void
        {
            this._instance = param1;
            this.showItem(param1.show);
            shuoming.toolTip = param1.tips.replace(/#""#/g, "\n");
            var _loc_3:* = param2[InstancesPublic.HESHANGTATINGINFO];
            if (_loc_3 == null)
            {
                return;
            }
            label_num.text = _loc_3.num;
            if (_loc_3.isDoorOpen == 1)
            {
                label_num1.label = "开启";
                label_num1.labelColors = "0x53b436,0xe19f21,0x53b436,0xe19f21";
                label_num1.addEventListener(MouseEvent.CLICK, this.moveClickHandler);
            }
            else
            {
                label_num1.label = "未开启";
                label_num1.labelColors = "0xc72514,0xc72514,0xc72514,0xc72514";
                label_num1.removeEventListener(MouseEvent.CLICK, this.moveClickHandler);
            }
            return;
        }// end function

        protected function moveClickHandler(event:Event) : void
        {
            ModelProxy.change("zone", "autoMove", {x:16, y:44});
            return;
        }// end function

        private function showItem(param1:String) : void
        {
            var _loc_2:* = new ItemSplit();
            var _loc_3:* = _loc_2.doSplits(param1, "&", "/", "#");
            list.array = _loc_3[0];
            list.renderHandler = new Handler(this.itemRender);
            return;
        }// end function

        private function itemRender(param1:Component, param2:int) : void
        {
            if (param2 < list.length)
            {
                (param1 as FlashItem).data = list.array[param2];
            }
            return;
        }// end function

        public function updateShow(param1:int, param2:Object) : void
        {
            switch(param1)
            {
                case InstancesPublic.TIMECHECKER:
                {
                    txt_time.text = TimeDataFormatUtil.getLeftTime(int(param2));
                    break;
                }
                case InstancesPublic.HESHANGTATINGINFO:
                {
                    label_num.text = param2.num;
                    if (param2.isDoorOpen == 1)
                    {
                        label_num1.label = "开启";
                        label_num1.labelColors = "0x53b436,0xe19f21,0x53b436,0xe19f21";
                        label_num1.addEventListener(MouseEvent.CLICK, this.moveClickHandler);
                    }
                    else
                    {
                        label_num1.label = "未开启";
                        label_num1.labelColors = "0xc72514,0xc72514,0xc72514,0xc72514";
                        label_num1.removeEventListener(MouseEvent.CLICK, this.moveClickHandler);
                    }
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function destroyShow(param1:Dictionary) : void
        {
            return;
        }// end function

        public function initEvent() : void
        {
            return;
        }// end function

        public function removeEvent() : void
        {
            return;
        }// end function

    }
}
